package com.zjut.azhen.DBDesign.mapping;

import com.zjut.azhen.DBDesign.bean.Role;
import com.zjut.azhen.DBDesign.bean.User;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Repository
public interface UserMapper {


//    @Results(id="userResult" ,value = {
//            @Result(property="id",column = "Id"),
//            @Result(property = "username",column = "username"),
//            @Result(property = "password",column = "password")
//    })
    @Select("select * from zhengjy_Users where id=#{username}")
    User loadUserByUsername(String username);

    @Results(id="user" ,value = {
            @Result(property="rno",column = "Rno"),
            @Result(property = "rname",column = "Rname"),
    })
    @Select("select zr.Rno Rno,Rname from zhengjy_Roles INNER JOIN zhengjy_ru zr on zhengjy_Roles.Rno = zr.Rno AND Id=#{id}")
    Role getRoleById(String id);

}
